package com.keqing.controller;

import com.ganyu.domain.ResponseResult;
import com.ganyu.domain.vo.AdminAddLinkVo;
import com.ganyu.domain.vo.AdminLinkVo;
import com.ganyu.service.impl.LinkServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * DATA: 2022/10/2
 * Author: 晨夕
 */
@RestController
@RequestMapping("/content/link")
public class AdminLinkController {

    @Autowired
    private LinkServiceImpl linkServiceImpl;

    @GetMapping("/list")
    public ResponseResult getLinkList(Integer pageNum , Integer pageSize,String name,String status){
        return linkServiceImpl.getLinkList(pageNum,pageSize,name,status);
    }
    @PreAuthorize("@ps.hasPermission()")
    @PostMapping
    public ResponseResult addLinkList(@RequestBody AdminAddLinkVo adminAddLinkVo){
        return linkServiceImpl.addLinkList(adminAddLinkVo);
    }

    @GetMapping("/{id}")
    public ResponseResult getLinkById(@PathVariable("id") Long id){
        return linkServiceImpl.getLinkById(id);
    }
    @PreAuthorize("@ps.hasPermission()")
    @PutMapping
    public ResponseResult updateLink(@RequestBody AdminLinkVo adminLinkVo){
        return linkServiceImpl.updateLink(adminLinkVo);
    }
    @PreAuthorize("@ps.hasPermission()")
    @DeleteMapping("/{id}")
    public ResponseResult deleteLink(@PathVariable("id") Long[] ids){
        return linkServiceImpl.deleteLink(ids);
    }
}
